﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>search()方法的应用示例</title>
</head>
<body>
    <p id="demo">单击显示查找的位置</p>
    <button onclick="myFunction()">查找</button>
    <script>
        function myFunction() {
            let str = "Hello JavaScript!";
            let n = str.search("JavaScript");
            document.getElementById("demo").innerHTML = n;
        }
    </script>
</body>
</html>